home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / interapplication comm / moreosl / moreappleevents / moreaeobjects.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  10.6 KB  |  271 lines

  1. /*
  2.     File:        MoreAEObjects.h
  3.  
  4.     Contains:    Functions to help you when you are working with Apple event objects.
  5.  
  6.     Written by:    George Warner
  7.  
  8.     Copyright:    Copyright (c) 2000 Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.  
  20.          <2>      9/3/00    Quinn   Fix initial checkin problem.
  21.          <1>      3/9/00    GW      Integrating AppleEvent Helper code. First Check In.
  22. */
  23.  
  24. #pragma once
  25. // %%%%% need to change calls to object building function to pass a boolean
  26. // %%%%% parameter to control the disposal of descs passed in.
  27. //********************************************************************************
  28. //    A private conditionals file to setup the build environment for this project.
  29. #include "MoreSetup.h"
  30. //**********    Universal Headers        ****************************************
  31. #include <AERegistry.h>
  32. #include <AEObjects.h>
  33. #include <AEPackObject.h>
  34. #include <Aliases.h>
  35. #include <Icons.h>
  36. //********************************************************************************
  37. #ifdef __cplusplus
  38.     extern "C" {
  39. #endif
  40.  
  41. #if PRAGMA_IMPORT
  42.     #pragma import on
  43. #endif
  44.  
  45. #if PRAGMA_STRUCT_ALIGN
  46.     #pragma options align=mac68k
  47. #elif PRAGMA_STRUCT_PACKPUSH
  48.     #pragma pack(push, 2)
  49. #elif PRAGMA_STRUCT_PACK
  50.     #pragma pack(2)
  51. #endif
  52. /********************************************************************************
  53.     Add a parameter of type typeAlias to an AERecord (or AppleEvent) using the provided FSSpec.
  54.  
  55.     pFSSpec            input:    Pointer to the FSSpec to use.
  56.     pKeyword        input:    The key for the data to be added to the record.
  57.     pAERecord        input:    Pointer to the record (or event) to add the data to.
  58.     
  59.     RESULT CODES
  60.     ____________
  61.     noErr               0    No error    
  62.     paramErr         -50    The value of target or alias parameter, or of
  63.                             both, is NIL, or the alias record is corrupt
  64.     memFullErr        -108    Not enough room in heap zone    
  65. */
  66. extern pascal    OSErr    MoreAEOAddAliasParameterFromFSSpec(const FSSpecPtr pFSSpec,
  67.                                                 const DescType pKeyword,
  68.                                                 AERecord *pAERecord );
  69. /********************************************************************************
  70.     Create and return an AEDesc of type typeAlias using the provided FSSpec.
  71.  
  72.     pFSSpec            input:    Pointer to the FSSpec to use.
  73.     pAliasAEDesc    input:    Pointer to null AEDesc.
  74.                     output:    an AEDesc of type typeAlias.
  75.     
  76.     RESULT CODES
  77.     ____________
  78.     noErr               0    No error    
  79.     paramErr         -50    The value of target or alias parameter, or of
  80.                             both, is NIL, or the alias record is corrupt
  81.     memFullErr        -108    Not enough room in heap zone    
  82. */
  83. extern pascal    OSErr    MoreAEOCreateAliasDescFromFSSpec( const FSSpecPtr pFSSpec,
  84.                                                   AEDesc *pAliasAEDesc );
  85. /********************************************************************************
  86.     Create and return an AEDesc of type typeAlias using the provided 
  87.     alias record.
  88.  
  89.     aliasHandle        input:    Handle to an alias record.
  90.     pAliasAEDesc    input:    Pointer to null AEDesc.
  91.                     output:    an AEDesc of type typeAlias.
  92.     
  93.     RESULT CODES
  94.     ____________
  95.     noErr               0    No error    
  96.     memFullErr        -108    Not enough room in heap zone    
  97. */
  98. extern pascal OSErr MoreAEOCreateAliasDesc( const AliasHandle aliasHandle,
  99.                                      AEDesc *pAliasAEDesc );
  100. /********************************************************************************
  101.     Given an FSSpec, return an object descriptor containing an alias,
  102.     contained by containerObj.
  103.     
  104.     pFSSpec            input:    Pointer to the FSSpec to use.
  105.     containerObjPtr    input:    Pointer to container object for object being created.
  106.     aliasObjectPtr    input:    Pointer to null AEDesc.
  107.                     output:    an alias object.
  108.     
  109.     RESULT CODES
  110.     ____________
  111.     noErr                    0    No error    
  112.     paramErr              -50    The value of target or alias parameter, or of
  113.                                 both, is NIL, or the alias record is corrupt
  114.     memFullErr             -108    Not enough room in heap zone    
  115.     errAECoercionFail     -1700    Data could not be coerced to the requested 
  116.                                 Apple event data type    
  117.     errAEWrongDataType    -1703    Wrong Apple event data type    
  118.     errAENotAEDesc        -1704    Not a valid descriptor record    
  119.     errAEBadListItem    -1705    Operation involving a list item failed    
  120. */
  121. extern pascal    OSErr    MoreAEOCreateAliasObjectFromFSSpec( const FSSpecPtr pFSSpec,
  122.                                                     AEDesc *containerObjPtr,
  123.                                                     AEDesc *aliasObjectPtr );
  124. /********************************************************************************
  125.     Given an AliasHandle, return an object descriptor containing an alias,
  126.     contained by containerObj.
  127.     
  128.     aliasHandle        input:    Handle to an alias record.
  129.     containerObjPtr    input:    Pointer to container object for object being created.
  130.     aliasObjectPtr    input:    Pointer to null AEDesc.
  131.                     output:    an alias object.
  132.     
  133.     RESULT CODES
  134.     ____________
  135.     noErr                    0    No error    
  136.     paramErr              -50    Error in parameter list
  137.     memFullErr             -108    Not enough room in heap zone    
  138.     errAECoercionFail     -1700    Data could not be coerced to the requested 
  139.                                 Apple event data type    
  140.     errAEWrongDataType    -1703    Wrong Apple event data type    
  141.     errAENotAEDesc        -1704    Not a valid descriptor record    
  142.     errAEBadListItem    -1705    Operation involving a list item failed    
  143. */
  144. extern pascal    OSErr    MoreAEOCreateAliasObject( const AliasHandle aliasHandle,
  145.                                           AEDesc *containerObjPtr,
  146.                                           AEDesc *aliasObjectPtr );
  147. /********************************************************************************
  148.     Given a property type, create an new object descriptor for that property,
  149.     contained by containerObj.
  150.     
  151.     propType        input:    Property type to use for object.
  152.     containerObjPtr    input:    Pointer to container object for object being created.
  153.     propertyObjPtr    input:    Pointer to null AEDesc.
  154.                     output:    A property object.
  155.     
  156.     RESULT CODES
  157.     ____________
  158.     noErr                    0    No error    
  159.     paramErr              -50    Error in parameter list
  160.     memFullErr             -108    Not enough room in heap zone    
  161.     errAECoercionFail     -1700    Data could not be coerced to the requested 
  162.                                 Apple event data type    
  163.     errAEWrongDataType    -1703    Wrong Apple event data type    
  164.     errAENotAEDesc        -1704    Not a valid descriptor record    
  165.     errAEBadListItem    -1705    Operation involving a list item failed    
  166. */
  167. extern pascal    OSErr    MoreAEOCreatePropertyObject( const DescType propType,
  168.                                              AEDesc *containerObjPtr,
  169.                                              AEDesc *propertyObjPtr );
  170. /********************************************************************************
  171.     Given a ProcessSerialNumber, create an new object descriptor for the PSN,
  172.     contained by containerObj.
  173.     
  174.     psnPtr            input:    ProcessSerialNumber to use for object.
  175.     containerObjPtr    input:    Pointer to container object for object being created.
  176.     psnObjPtr        input:    Pointer to null AEDesc.
  177.                     output:    A ProcessSerialNumber object.
  178.     
  179.     RESULT CODES
  180.     ____________
  181.     noErr                    0    No error    
  182.     paramErr              -50    Error in parameter list
  183.     memFullErr             -108    Not enough room in heap zone    
  184.     errAECoercionFail     -1700    Data could not be coerced to the requested 
  185.                                 Apple event data type    
  186.     errAEWrongDataType    -1703    Wrong Apple event data type    
  187.     errAENotAEDesc        -1704    Not a valid descriptor record    
  188.     errAEBadListItem    -1705    Operation involving a list item failed    
  189. */
  190. extern pascal    OSErr    MoreAEOCreateProcessObject( const ProcessSerialNumber *psnPtr,
  191.                                             AEDesc *containerObjPtr,
  192.                                             AEDesc *psnObjPtr );
  193. /********************************************************************************
  194.     Given selection type, create an new object descriptor for a selection,
  195.     contained by containerObj.
  196.     
  197.     selection        input:    Selection type to use for object.
  198.     containerObjPtr    input:    Pointer to container object for object being created.
  199.     selectionObject    input:    Pointer to null AEDesc.
  200.                     output:    A property object.
  201.     
  202.     RESULT CODES
  203.     ____________
  204.     noErr                    0    No error    
  205.     paramErr              -50    Error in parameter list
  206.     memFullErr             -108    Not enough room in heap zone    
  207.     errAECoercionFail     -1700    Data could not be coerced to the requested 
  208.                                 Apple event data type    
  209.     errAEWrongDataType    -1703    Wrong Apple event data type    
  210.     errAENotAEDesc        -1704    Not a valid descriptor record    
  211.     errAEBadListItem    -1705    Operation involving a list item failed    
  212. */
  213. extern pascal    OSErr    MoreAEOCreateSelectionObject( const DescType selection,
  214.                                               AEDesc *containerObjPtr,
  215.                                               AEDesc *selectionObject );
  216. /********************************************************************************
  217.     Make position list (a list containing two longs representin the x and y values
  218.     for the position of a Finder item).
  219.     
  220.     position            input:    A point specifying the position.
  221.     pPositionAEList        input:    Pointer to an AEList (contents will be lost, but not disposed).
  222.                         output:    A new AEList containing the x & y values for the position.
  223.     
  224.     Result Codes
  225.     ____________
  226.     noErr                    0    No error    
  227.     memFullErr             -108    Not enough room in heap zone    
  228. */
  229. extern pascal    OSErr    MoreAEOCreatePositionList( const Point position,
  230.                                      AEDescList *pPositionAEList );
  231.  
  232. //********************************************************************************
  233. // A simple wrapper around CreateObjSpecifier which creates
  234. // an object specifier using formUniqueID and the unique ID
  235. // in pKeyData.
  236. pascal OSStatus MoreAEOCreateObjSpecifierFormUniqueID(DescType pDesiredClass, const AEDesc *pContainer, 
  237.                                                 SInt32 pKeyData, Boolean pDisposeInputs, 
  238.                                                 AEDesc *pObjSpecifier);
  239. //********************************************************************************
  240. // A simple wrapper around CreateObjSpecifier which creates
  241. // an object specifier using formAbsolutePosition, a key of
  242. // typeLongInteger (rather than typeAbsoluteOrdinal) and the
  243. // position index in pKeyData.
  244. pascal OSStatus MoreAEOCreateObjSpecifierFormAbsPos(DescType pDesiredClass, const AEDesc *pContainer, 
  245.                                             SInt32 pKeyData, SInt32 pDisposeInputs, 
  246.                                             AEDesc *pObjSpecifier);
  247. //********************************************************************************
  248. // A simple wrapper around CreateObjSpecifier which creates
  249. // an object specifier using formName and the name in pKeyData.
  250. pascal OSStatus MoreAEOCreateObjSpecifierFormName(DescType pDesiredClass, const AEDesc *pContainer, 
  251.                                             ConstStr255Param pKeyData, Boolean pDisposeInputs, 
  252.                                             AEDesc *pObjSpecifier);
  253. //********************************************************************************
  254. #if PRAGMA_STRUCT_ALIGN
  255.     #pragma options align=reset
  256. #elif PRAGMA_STRUCT_PACKPUSH
  257.     #pragma pack(pop)
  258. #elif PRAGMA_STRUCT_PACK
  259.     #pragma pack()
  260. #endif
  261.  
  262. #ifdef PRAGMA_IMPORT_OFF
  263. #pragma import off
  264. #elif PRAGMA_IMPORT
  265. #pragma import reset
  266. #endif
  267.  
  268. #ifdef __cplusplus
  269. }
  270. #endif
  271.